<?php
// remove spam
function remove_headers($string) { 
	$headers = array(
		"/to\:/i",
		"/from\:/i",
		"/bcc\:/i",
		"/cc\:/i",
		"/href/i",
		"/http/i",
		"/www/i",
		"/Content\-Transfer\-Encoding\:/i",
		"/Content\-Type\:/i",
		"/Mime\-Version\:/i"  
	); 
	if (preg_replace($headers, '', $string) == $string) {
		return $string;
	} else {
		header						("Location: sorry.php");
		die							();
	}
}

// general setup
$to 								= "rob@bytemedia.co.uk";
$subject 							= "Callback Form Submission From printing.com site";
// convert values
$nospam_firstname 					= remove_headers($_POST['firstname']);
$nospam_lastname 					= remove_headers($_POST['lastname']);
$nospam_email 						= remove_headers($_POST['email']);
$nospam_phone						= remove_headers($_POST['phone']);
$nospam_message 					= remove_headers($_POST['message']);

// begin message
$headers 							= "From: ".$nospam_firstname." <".$nospam_email.">";
$message 							= "This email has been received via your website\r\n\r\n"
									."First Name: ".$nospam_firstname."\r\n"
									."Last Name: ".$nospam_lastname."\r\n"
									."Email: ".$nospam_email."\r\n"
									."Telephone: ".$nospam_phone."\r\n"
									."Message: ".$nospam_message."\r\n"
									
									
									;
									
									if($nospam_email != "") {
										mail ($to, $subject, $message, $headers);
									}

header 								("Location: thanks.php");
?>